package tools;

import net.sf.json.JSONObject;



public class JsonTestEntity {
	public static void main(String[] args) {
		// String categoryString
		// =FileUtil.readFileByLines("/home/dsw/workspaces/workspace07/operator/src/main/webapp/data/category");
		String categoryString = "{'id':0,'value':'Root',"
				+ "'children':[{'id':10108,'value':'人口属性','children':"
				+ "[{'id':10109,'value':'性别','children':[{'id':10110,'value':'男性','children':null},"
				+ "{'id':10111,'value':'女性','children':null}]},{'id':10112,'value':'年龄',"
				+ "'children':[{'id':10113,'value':'7-12','children':null},{'id':10114,'value':'13-18','children':null},"
				+ "{'id':10115,'value':'19-22','children':null},{'id':10116,'value':'23-28','children':null},"
				+ "{'id':13861,'value':'29-35','children':null},{'id':10117,'value':'36-50','children':null},"
				+ "{'id':10118,'value':'50岁以上','children':null}]},{'id':10119,'value':'月收入','children':"
				+ "[{'id':10120,'value':'4000元以下','children':null},{'id':10123,'value':'4000-8000元','children':null},"
				+ "{'id':10125,'value':'8001-12000元','children':null},{'id':10126,'value':'12001-20000元','children':null},"
				+ "{'id':10127,'value':'20000以上','children':null}]},{'id':10128,'value':'身份职业','children':[{'id':10129,"
				+ "'value':'学生','children':null},{'id':10130,'value':'商务白领','children':null}]}]}]}";
		categoryString = "{'id':0,'value':'Root',children:null}";
		JSONObject category = JSONObject.fromObject(categoryString);
		CategoryEntity entity = (CategoryEntity) JSONObject.toBean(category, CategoryEntity.class);
	//	JSONObject.tobean
		System.out.println(entity.getId());
		System.out.println(entity.getValue());
		CategoryEntity en2 = new CategoryEntity();
		en2.setId(90);
		en2.setValue("fdsa");
		en2.setChildren(null);
		System.out.println(entity.getChildren());
		entity.getChildren().add(en2);
		System.out.println(JSONObject.fromObject(entity));
	}
}